import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/viewmodel/food_sample/add_food_sample_view_model.dart';

class AddFoodSamplePage extends BaseStatefulMvvmWidget{
  final String? id;
  final bool isChange;
  final String title;

  AddFoodSamplePage({this.id, this.isChange = false,this.title="留样登记"});

  @override
  State<StatefulWidget> createState() => _AddFoodSampleState();

}

class _AddFoodSampleState extends BaseMvvmState<AddFoodSampleViewModel,AddFoodSamplePage>{
  @override
  Widget buildLoadingContentView() {
    return viewModel.contentView();
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title),),
      body: loadingContentWidget,
      floatingActionButton: widget.isChange? FloatingActionButton(onPressed: (){
        viewModel.addFoodSample();
      },child: Icon(Icons.add),):Container(),
    );
  }

  @override
  AddFoodSampleViewModel createViewModel() {
    return AddFoodSampleViewModel(context,id: widget.id,isChange: widget.isChange);
  }

  @override
  void onRetryClick() {
    viewModel.requestNetData();
  }

}